package com.jsmile.cloud.tradecenter.order.model;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author 龚亮
 * @version 1.0
 * @desc 为了薪资破万，还是睡一会儿吧...!
 * @date 2019年12月19日 02:56:26
 */
@ApiModel
@Data
@TableName("t_order_address")
public class OrderAddress extends Model<OrderAddress> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @ApiModelProperty(value = "user_id")
    private Long userId;
    @ApiModelProperty(value = "订单编号")
    private Long orderNo;
    @ApiModelProperty(value = "地址类型")
    private Integer addressType;
    @ApiModelProperty(value = "联系人")
    private String contactName;
    @ApiModelProperty(value = "联系电话")
    private String phone;
    @ApiModelProperty(value = "省")
    private String province;
    @ApiModelProperty(value = "市")
    private String city;
    @ApiModelProperty(value = "区")
    private String district;
    @ApiModelProperty(value = "街道")
    private String street;
    @ApiModelProperty(value = "详细信息")
    private String detailAddress;
    @ApiModelProperty(value = "邮编")
    private String zip;
    @ApiModelProperty(value = "latitude")
    private java.math.BigDecimal latitude;
    @ApiModelProperty(value = "longitude")
    private java.math.BigDecimal longitude;
    @ApiModelProperty(value = "区域编码")
    private String adcode;
    @ApiModelProperty(value = "收货时间起")
    private Date deliveryStartTime;
    @ApiModelProperty(value = "收货时间止")
    private Date deliveryEndTime;
    @ApiModelProperty(value = "create_time")
    private Date createTime;
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
    @ApiModelProperty(value = "del_flag")
    @TableLogic
    private Integer delFlag;
    @ApiModelProperty(value = "发货人姓名")
    private String sendName;
    @ApiModelProperty(value = "租户id")
    private Long tenantId;
    @ApiModelProperty(value = "发货人电话")
    private String sendPhone;
    @ApiModelProperty(value = "发货人地地")
    private String sendAddress;
    @ApiModelProperty(value = "发货时间")
    private Date sendTime;
    @ApiModelProperty(value = "平台id")
    private Integer platformId;
    @ApiModelProperty(value = "业务id")
    private Integer bizCode;

    public static OrderAddress create(Order order, Long addressId) {
        OrderAddress orderAddress = null;
        // if (DeliveryTypeEnum.SELF.getValue() == order.getDeliveryType()) {//自提取店铺地址
        // orderAddress = new OrderAddress();
        // orderAddress.setAddressType(AddressTypeEnum.SHOP.getValue());
        // } else {
        // if (null != addressId) {
        // JSmileResult<ResUserAddress> jSmileResult = SpringKit.getBean(AddressServiceApi.class)
        // .getUserAddress(ReqAddressDetial.builder().addressId(addressId).build());
        // if (jSmileResult.getResSuccess()) {
        // orderAddress = BeanUtil.toBean(jSmileResult.getResData(), OrderAddress.class);
        // }
        // }
        // }
        // if (null != orderAddress) {
        // orderAddress.setOrderNo(order.getId());
        // orderAddress.setCreateTime(new Date());
        // orderAddress.setUserId(order.getUserId());
        // }
        return orderAddress;
    }
}
